<?php

/**
 * Account form base class.
 *
 * @method Account getObject() Returns the current form's model object
 *
 * @package    corpon
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseAccountForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_account'       => new sfWidgetFormInputHidden(),
      'account_name'     => new sfWidgetFormInputText(),
      'company_name'     => new sfWidgetFormInputText(),
      'company_name_url' => new sfWidgetFormInputText(),
      'company_logo'     => new sfWidgetFormInputText(),
      'contract_date'    => new sfWidgetFormDate(),
      'contract_exp'     => new sfWidgetFormDate(),
      'contract_term'    => new sfWidgetFormInputText(),
      'ref_contact'      => new sfWidgetFormInputText(),
      'shipping_address' => new sfWidgetFormInputText(),
      'shipping_state'   => new sfWidgetFormInputText(),
      'shipping_city'    => new sfWidgetFormInputText(),
      'shipping_zip'     => new sfWidgetFormInputText(),
      'billing_address'  => new sfWidgetFormInputText(),
      'billing_state'    => new sfWidgetFormInputText(),
      'billing_city'     => new sfWidgetFormInputText(),
      'billing_zip'      => new sfWidgetFormInputText(),
      'billing_phone'    => new sfWidgetFormInputText(),
      'billing_email'    => new sfWidgetFormInputText(),
      'billing_email2'   => new sfWidgetFormInputText(),
      'billing_contact'  => new sfWidgetFormInputText(),
      'created_at'       => new sfWidgetFormDateTime(),
      'account_comments' => new sfWidgetFormTextarea(),
    ));

    $this->setValidators(array(
      'id_account'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_account')), 'empty_value' => $this->getObject()->get('id_account'), 'required' => false)),
      'account_name'     => new sfValidatorString(array('max_length' => 255)),
      'company_name'     => new sfValidatorString(array('max_length' => 150)),
      'company_name_url' => new sfValidatorString(array('max_length' => 150)),
      'company_logo'     => new sfValidatorString(array('max_length' => 75, 'required' => false)),
      'contract_date'    => new sfValidatorDate(),
      'contract_exp'     => new sfValidatorDate(),
      'contract_term'    => new sfValidatorString(array('max_length' => 255)),
      'ref_contact'      => new sfValidatorString(array('max_length' => 150)),
      'shipping_address' => new sfValidatorString(array('max_length' => 255)),
      'shipping_state'   => new sfValidatorString(array('max_length' => 75)),
      'shipping_city'    => new sfValidatorString(array('max_length' => 100)),
      'shipping_zip'     => new sfValidatorString(array('max_length' => 40)),
      'billing_address'  => new sfValidatorString(array('max_length' => 255)),
      'billing_state'    => new sfValidatorString(array('max_length' => 75)),
      'billing_city'     => new sfValidatorString(array('max_length' => 100)),
      'billing_zip'      => new sfValidatorString(array('max_length' => 40)),
      'billing_phone'    => new sfValidatorString(array('max_length' => 40)),
      'billing_email'    => new sfValidatorString(array('max_length' => 80)),
      'billing_email2'   => new sfValidatorString(array('max_length' => 80)),
      'billing_contact'  => new sfValidatorString(array('max_length' => 150)),
      'created_at'       => new sfValidatorDateTime(),
      'account_comments' => new sfValidatorString(array('max_length' => 500, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Account', 'column' => array('company_name_url')))
    );

    $this->widgetSchema->setNameFormat('account[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Account';
  }

}
